package com.hexinfo.dmpro.sparing.model;

import com.hexinfo.dmpro.component.comparison.enums.TableContrastEnums;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * 热备同步表
 *
 * @author zax
 * @date 2023-08-29 17:55:32
 */
@Data
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false,of = {"sourceAddress","targetAddress"})

@NoArgsConstructor
public class HdfsHeatBackup {

    //源hdfs地址
    private String sourceAddress;
    //备份hdfs地址(变库不变表)
    private String backupAddress;
    //目标hdfs地址
    private String targetAddress;
    //源库名
    private String sourceDbName;
    //备份库(变库不变表)
    private String backupDbName;
    //目标库
    private String targetDbName;
    //源表名
    private String sourceTableName;
    //备份表名(变库不变表)
    private String backupTableName;
    //目标表名
    private String targetTableName;
    //文件大小
    private Long fileSize;
    //符合要求的分区名,有无表示表有没有分区字段
    private String pkeyName;
    //同步范围 同步多久时间的数据 0为全量 数值为年数
    private Integer syncRange;


    //1：按源，2：时间窗口
    private String backupSort;
    //同步的源
    private String sourceData;

    public Long getFileSize() {
        return (fileSize == null) ? 0L : fileSize;
    }

    public String getSourceName() {
        return sourceDbName + "." + sourceTableName;
    }

    public String getSourceNameType() {
        return sourceData + "." + sourceDbName + "." + sourceTableName;
    }

    public String getContrastType() {
        return TableContrastEnums.WARM.getValue() + "." + sourceDbName + "." + sourceTableName;
    }

    public String getBackupName() {
        return backupDbName + "." + backupTableName;
    }

    public String getTargetName() {
        return targetDbName + "." + targetTableName;
    }

}
